﻿using System;

namespace OracleTools.Core
{
    public class EnvVarManager
    {
        private static EnvVarManager m_this = null;
        public static EnvVarManager GetInstance()
        {
            return m_this == null ? new EnvVarManager() : m_this;
        }

        public void UpdateValue(string psVariable, string psValue, EnvironmentVariableTarget target)
        {
            string sEnv = Environment.GetEnvironmentVariable(psVariable, target);
            if (!string.IsNullOrWhiteSpace(sEnv))
                SetValue(psVariable, psValue, target);
        }

        public void SetValue(string psVariable, string psValue, EnvironmentVariableTarget target)
        {
            Environment.SetEnvironmentVariable(psVariable, psValue, target);
            LogWriter.LogLine("<{0}> {1} = {2}", target, psVariable, psValue);
        }

    }
}
